<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Env;

class QnrTags extends Model
{

    use HasDateTimeFormatter;

    protected $table = 'qnr_tags';

    /**
     * 可以被批量赋值的属性。
     *
     * @var array
     */
    protected $fillable = [
        't_key' ,
        'name' ,
        'sort_id' ,
        'description' ,
        'is_using' ,
    ];

    /**
     * 获取分类 (选项卡)
     *
     * @return array
     */
    public static function getClsSelect()
    {

        // 分类
        $dataClassify = static::where('is_using' , Env::get('APP_CONTENT_STATE'))->get();

        // 初始化
        $result = [];

        if(empty($dataClassify)){
            return $result;
        }

        foreach( $dataClassify as $value ) {

            if(empty($value['t_key'])){
                continue;
            }

            $result[$value['t_key']] = $value['name'];
        }

        return $result;
    }
}
